<?php
require 'Admin/Controller/Controller.php ';
require 'Admin/Model/newstypeModel.php';
class NewsTypeController extends Controller{
	function __Construct(){
		parent::__Construct();
		$this->mod = 'newstype';
	}
	function newstypelist(){
		/*$data = array(
			array('uname'=>'jason','gender'=>'男'),
			array('uname'=>'jack','gender'=>'男')
			);*/
		$model = new NewsTypeModel();
		$data = $model->getNewsTypeList();
		$this->assign('newstype',$data);
		$this->display(); 
		//return $data;

	}
	function form(){
		$this->display();
	}
	function regnewstype(){
		$data = $_POST;
		$model = new NewsTypeModel();
		$result = $model->addNewsType($data);
		if($result){
			echo '添加成功 <a href="admin.php?c=newstype&m=newstypelist">如果没有跳转，请点这里跳转</a>';
   			//header("refresh:3;url='admin.php?c=newstype&m=newstypelist'");
		}
		else{
			echo "添加失败！<br/>";
  			echo "<a href='admin.php?c=newstype&m=newstypelist'>返回</a>";
		}
	}
	function editnewstype(){
		$id = $_GET['ntid'];
		$model = new NewsTypeModel();
		$result = $model->getNewsTypeByID($id);
		$this->assign('newstype',$result);
		$this->display(); 
	}

	function update(){
		$data = $_POST;
		//var_dump($date);
		$model = new NewsTypeModel();
		$result = $model->updateNewsType($data);
		//var_dump($result);
		if($result){
			echo '更新成功 <a href="admin.php?c=newstype&m=newstypelist">如果没有跳转，请点这里跳转</a>';
   			header("refresh:3;url='admin.php?c=newstype&m=newstypelist'");
		}
		else{
			echo "更新失败！<br/>";
  			echo "<a href='admin.php?c=newstype&m=newstypelist&ntid=".$data['id']."'>返回</a>";
		}
	}
	function delnewstype(){
		$id = $_GET['id'];
		$model = new NewsTypeModel();
		$result = $model->delNewsType($id);

		if($result){
			echo '删除成功 <a href="admin.php?c=newstype&m=newstypelist">如果没有跳转，请点这里跳转</a>';
   			//header("refresh:3;url='admin.php?c=newstype&m=newstypelist'");
		}
		else{
			echo "删除失败！<br/>";
  			echo "<a href='admin.php?c=newstype&m=newstypelist'>返回</a>";
		}
	}
	function search(){
		$a=$_POST;
		$model= new NewsTypeModel();
		$data= $model->Search($a['key']);
		if($data){
   			$this->assign('newstype',$data);
		$this->display();
		}
		else{
			echo "没有数据！<br/>";
  			echo "<a href='admin.php?c=newstype&m=newstypelist'>返回</a>";
		}
		
	}


}
?>